package iscript.uiFramework.components.window
{
	import flash.display.BitmapData;
	import iscript.uiFramework.components.container.ScrollBox;
	import iscript.uiFramework.components.toolButton.*;
	import iscript.uiFramework.event.WindowEvent;
	import iscript.uiFramework.UIFramework;
	import iscript.uiFramework.util.Scale9GridBitmap;
	
	public class Window extends AbstractWindow 
	{
 
		
		protected var windowSkin:Scale9GridBitmap;
		protected var header:WindowHeader;
		private var _body:ScrollBox;

		
		public function Window()
		{
			_preferWidth = 300;
			_preferHeight = 300;
			super();
		}
		
		override protected function initialize():void 
		{
				
			windowSkin = new Scale9GridBitmap(UIFramework.resource.getBitmapData("GameLite.UIComponent." + this.theme + ".Window"), 
											  UIFramework.resource.getElementRectangle("Window", this.theme));
			windowSkin.width = super._preferWidth;
			windowSkin.height = super._preferHeight;
			addChild(windowSkin);
			
			header = new WindowHeader();
			header.width = _preferWidth;
			header.closeButton.ClickHandler = function():void
			{
				close();
				
			}
			header.render(this);
			
			_body = new ScrollBox(super._preferWidth - 10, super._preferHeight - header.height - 5);
			_body.background = true;
			_body.getBackground().begFillColor(0xFFFFFF);
			_body.x = 5
			_body.y = header.height;
			_body.border = true;
			_body.getBorder().color = 0xA2B0C4
			_body.render(this);
			//this.shadow = true;
			super.initialize();
		}
		
		public function set title(value:String):void {
			 header.text = value;
			}
		
		public function get title():String {
			return header.text;
			}
		 
		public function get icon():BitmapData
		{
			return header.icon;
		}
		
		public function set icon(value:BitmapData):void
		{
			header.icon = value;
		}	
			
			
		override public function set width(value:Number):void
		{
			windowSkin.width = value;
			header.width = value;
			_body.width = value - 10;
		}
		
		override public function set height(value:Number):void
		{
			windowSkin.height = value;
			header.height = value;
			_body.height = value - header.height - 5;
		}
		
		override public function get width():Number
		{
			return windowSkin.width;
		}
		
		override public function get height():Number
		{
			return windowSkin.height;
		}
		
		public function get body():ScrollBox 
		{
			return _body;
		}
		
		
	
	}

}